import java.util.Scanner;

public class Code1 {

    public static void main(String[] args) {
        //100-999999之间的水仙花数
        for(int i = 0;i < 999999;i++){
            //先求i是几位数
            int count = 0;
            int tmp = i;
            while(tmp!=0){
                count++;
                tmp /= 10;
            }

            //求每一位上是几
            tmp = i;
            int sum = 0;
            while(tmp != 0){
                sum += Math.pow(tmp % 10,count);
                tmp /=10;
            }
            if(sum==i){
                System.out.println(i);
            }
        }
    }

    public static void main5(String[] args) {
        //0-999之间的水仙花数
        int num = 0;  //159
        int count = 0;
        for(num = 100;num<=999;num++){
            int a = num/100;
            int b = num%100/10;
            int c = num%10;
            if(num==Math.pow(a,3)+Math.pow(b,3)+Math.pow(c,3)){
                System.out.println(num+"是水仙花术");
                count++;
            }
        }
        System.out.println("一共有"+count+"个水仙花数");
    }


    public static void main4(String[] args) {
        //求两个正整数的最大公约数
        int a = 24;
        int b = 18;
        int c = a%b;
        while(c!=0){
            a = b;
            b = c;
            c = a%b;
        }
        System.out.println(b);
    }

    public static void main3(String[] args) {
        //判断最大最小 差
        int a = 10;
        int b = 20;
        System.out.println(Math.max(a, b));
        System.out.println(Math.min(a, b));
        System.out.println(Math.abs(a - b));
        System.out.println(Math.pow(2, 3));
    }


    public static void main2(String[] args) {
        //1-100之间的素数
        int num = 0;
        int i = 2;
        for(num=2;num<=100;num++){
            for(i=2;i<=Math.sqrt(num);i++){
                if(num%i==0){
                    System.out.println(num+"不是素数");
                    break;
                }
            }
            if(i>Math.sqrt(num)){
                System.out.println(num+"是素数");
                //break;
            }
        }
    }

    public static void main1(String[] args) {
        //判断素数
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数：");
        int mun = scanner.nextInt();
        int i = 2;
        for(i = 2;i<=Math.sqrt(mun);i++){
            if(mun%i==0){
                System.out.println(mun+"不是素数");
                break;
            }
        }
        if(i >Math.sqrt(mun)){
            System.out.println(mun+"是素数");
        }


    }
}
